# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import MySQLdb
from django.shortcuts import render

# from .models import UserMessage
# Create your views here.

# def getform(request):
#     # 查询数据库中的信息
#     # all_messages = UserMessage.objects.all()
#     # and查询
#     # all_messages = UserMessage.objects.filter(name='boboy',address='北京')
#     # for message in all_messages:
#     #     print message.name
#
#     # 删除数据，先查询在删除
#     # all_messages = UserMessage.objects.filter(name='boboy', address='北京')
#     # all_messages.delete()
#
#
#     # user_message = UserMessage()
#     # user_message.name = 'boboy2'
#     # user_message.message = 'helloword2'
#     # user_message.address = '上海'
#     # user_message.email = '2@2.com'
#     # user_message.object_id = 'helloword2'
#     # # 数据库中添加信息
#     # user_message.save()
#
#     # 获取表单中的值，并添加在数据库中
#     # if request.method == 'POST':
#     #     name = request.POST.get('name','')
#     #     message = request.POST.get('message', '')
#     #     address = request.POST.get('address', '')
#     #     email = request.POST.get('email', '')
#     #
#     #     user_message = UserMessage()
#     #     user_message.name = name
#     #     user_message.message = message
#     #     user_message.address = address
#     #     user_message.email = email
#     #     user_message.object_id = 'helloword3'
#     #     # 数据库中添加信息
#     #     user_message.save()
#     message = None
#     all_message = UserMessage.objects.filter(name='boboytest2')
#     if all_message:
#         message = all_message[0]
#
#
#     return render(request,'message_form.html',{
#         'mymessage':message
#     })


